import ReactDOM from "react-dom";
import React from "react";
import {Router, Route, Link, browserHistory} from "react-router";
import Login from "../containers/Login";
import NotFound from "../containers/NotFound";
import "../common/lib";
import auth from "../common/auth";
import Home from "../containers/Home";
import App from "../containers/App";
import UserList from "../components/system/userlist"
import FuncList from "../components/system/funclist";
import RoleList from "../components/system/rolelist"
function requireAuth(nextState, replace) {
    if (!auth.loggedIn()) {
        replace({
            pathname: '/',
            state: {nextPathname: nextState.location.pathname}
        })
    }
}

ReactDOM.render((
  <Router  history={browserHistory}>
    <Route path="/" component={Login} />
    <Route path="/admin" breadcrumbName="主页" component={App}  onEnter={requireAuth} >
               <Route path="home"  component={Home}/>
               <Route path="userlist" breadcrumbName="用户管理" component={UserList}/>
               <Route path="rolelist" breadcrumbName="角色管理" component={RoleList}/>
               <Route path="funclist" breadcrumbName="菜单管理" component={FuncList}/>
    </Route>
    <Route path="*" component={NotFound} /> 
  </Router>
), document.getElementById('react-content'))
